//
//  CNCommentViewController.swift
//  Ccweibo
//
//  Created by 陈锦聪 on 16/4/5.
//  Copyright © 2016年 Coco. All rights reserved.
//

import UIKit
import SVProgressHUD

class CNCommentViewController: CNBaseInputViewController {

    override func viewDidLoad() {
        super.viewDidLoad()        
    }
    override func setupNavigationBar() {
        super.setupNavigationBar()
        navigationItem.title = "评论"
    }
    override func publishAction() {
        let comment = textView.emoticonsText()
        if comment.characters.count > statusMaxCount {
            SVProgressHUD.showErrorWithStatus("评论内容超过限定长度", maskType: SVProgressHUDMaskType.Black)
            return
        }
        SVProgressHUD.showWithStatus("正在发表评论...", maskType: SVProgressHUDMaskType.Gradient)
        CNStatusViewModel.sharedInstance.reposeStatus(id!, status: nil, comment: comment) { (error) -> () in
            if error != nil {
                SVProgressHUD.showErrorWithStatus("发表评论失败", maskType: SVProgressHUDMaskType.Black)
                CNPrint(item: "sendStatusAction: \(error)")
                return
            }
            SVProgressHUD.showSuccessWithStatus("发表评论成功", maskType: SVProgressHUDMaskType.Clear)
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (Int64)(500 * USEC_PER_SEC)), dispatch_get_main_queue(), { () -> Void in
                self.dismissAction()
            })
        }
    }
}
